package com.xbongbong.paas.print.model.impl;

import com.xbongbong.paas.domain.dao.PaasPrintTemplateDao;
import com.xbongbong.paas.domain.entity.PaasPrintTemplateEntity;
import com.xbongbong.paas.print.model.PaasPrintTemplateModel;
import com.xbongbong.paas.toolbox.util.DateUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 创建时间： 2018/9/11 11:30
 * 修改时间： 2018/9/11 11:30 梁鲁江
 *
 * @author 梁鲁江
 */
@Service("paasPrintTemplateMode")
public class PaasPrintTemplateModelImpl implements PaasPrintTemplateModel {

    @Resource
    private PaasPrintTemplateDao paasPrintTemplateDao;

    @Override
    public Integer insert(PaasPrintTemplateEntity entity) {
        long now = DateUtil.getInt();
        entity.setAddTime(now);
        entity.setUpdateTime(now);
        return paasPrintTemplateDao.insert(entity);
    }
    @Override
    public Integer update(PaasPrintTemplateEntity entity) {
        entity.setUpdateTime((long) DateUtil.getInt());
        return paasPrintTemplateDao.update(entity);
    }

    @Override
    public Integer save(PaasPrintTemplateEntity entity) {
        if(entity.getId() == null || entity.getId().equals(0L)) {
            return insert(entity);
        }
        return update(entity);
    }

    @Override
    public List<PaasPrintTemplateEntity> list(Map<String, Object> params) {
        return paasPrintTemplateDao.findEntitys(params);
    }

    @Override
    public PaasPrintTemplateEntity getByKey(Long key, String corpid) {
        return paasPrintTemplateDao.getByKey(key, corpid);
    }

    @Override
    public Integer getEntitysCount(Map<String, Object> params) {
        return paasPrintTemplateDao.getEntitysCount(params);
    }

    @Override
    public Integer delete(Long key, String corpid) {
        return paasPrintTemplateDao.deleteByKey(key, corpid);
    }

    @Override
    public Integer insertBatch(List<PaasPrintTemplateEntity> defaultTemplateList) {
        return paasPrintTemplateDao.insertBatch(defaultTemplateList);
    }

    @Override
    public void updateBatchAll(List<PaasPrintTemplateEntity> updateList) {
        paasPrintTemplateDao.updateBatchAll(updateList);
    }

    @Override
    public void updateBatch(List<PaasPrintTemplateEntity> updateBatchList, String corpid) {
        paasPrintTemplateDao.updateBatch(updateBatchList, corpid);
    }

    @Override
    public Long getMaxId(Map<String, Object> param) {
        return paasPrintTemplateDao.getMaxId(param);
    }

}
